#define _CRT_SECURE_NO_WARNINGS
#include<iostream> 
#include<string>
using namespace std;

struct Tree {
	string str;
	struct Tree* H;
	struct Tree* L;
};
struct Tree* CreatTree(string c, struct Tree* T, int n, string str)
{
	if (T == NULL)
	{
		T = new struct Tree[sizeof(struct Tree)];
		T->str = str;
		T->H = NULL;
		T->L = NULL;
	}
	if (c[n] == 'H') T->H = CreatTree(c, T->H, n + 1, T->str + "H");
	else if (c[n] == 'L') T->L = CreatTree(c, T->L, n + 1, T->str + "L");
	else if (c[n] == 'Y' || c[n] == 'N') T->str = c[n];
	return T;
}
string FindString(struct Tree* T)
{
	struct Tree* p;
	p = T;
	string TH, TL;
	if (p == NULL) return " ";
	if (p->str == "Y" || p->str == "N")	return p->str;
	else
	{
		TH = FindString(p->H);
		TL = FindString(p->L);
	}
	if (TH == "Y" || TH == "N")
	{
		if (TL == TH) return TH;
		else if (TL == " ") return TH;
		else if (TL != TH) return T->str + "H" + TH + T->str + "L" + TL;
	}
	else if (TL == "Y" || TL == "N")
	{
		if (TH == TL) return TL;
		else if (TH == " ") return TL;
		else if (TH != TL) return T->str + "H" + TH + T->str + "L" + TL;
	}
	else if (TH != TL) return T->str + TH + T->str + TL;
	return T->str;
}
int main()
{
	struct Tree* T;
	T = NULL;
	int N, M;
	string* str, S;
	char c;
	cin >> N >> M;
	str = new string[N];

	for (int i = 0; i < N; i++)
	{
		for (int j = 0;; j++)
		{
			cin >> c;
			if (c == 'H' || c == 'L' || c == 'Y' || c == 'N') str[i] += c;
			if (c == 'Y' || c == 'N')break;
		}
	}
	for (int i = 0; i < N; i++)
	{
		T = CreatTree(str[i], T, 0, " ");

	}
	S = FindString(T);
	int Begin = 0;
	for (int i = 0; S[i] != '\0'; i++)
	{
		if (S[i] == ' ') Begin = i + 1;
		else if (S[i] == 'Y' || S[i] == 'N')
		{
			for (int j = Begin; j <= i; j++)
			{
				cout << S[j];
			}
			cout << ";";
		}
	}
	return 0;
}